From 14c507c47d4e1282a32d1f922b5036af967a17cd Mon Sep 17 00:00:00 2001 From: robertl Date: Sat, 17 May 2003 19:30:21 +0000 Subject: [PATCH] Rick Richardson wrote: > This patch adds.. > > - fix for Makefile > - Teach geo.c how to read the and stick it in icon_descr. > N.B. not sure I did this 100% right > - Teach gpsdrive.style how to output icon_descr as the "category". --- gpsbabel/Makefile | 2 +- gpsbabel/geo.c | 36 +++++++++++++++++++++++++++++++++ gpsbabel/internal_styles.c | 8 +++++--- gpsbabel/reference/gl.loc | 9 +++++++++ gpsbabel/reference/gpsdrive.txt | 18 ++++++++--------- gpsbabel/style/gpsdrive.style | 8 +++++--- 6 files changed, 65 insertions(+), 16 deletions(-) diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index ec7bcef8a..d38a62f2f 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -165,4 +165,4 @@ jeeps/gpsutil.o: jeeps/gpsutil.c jeeps/gps.h jeeps/gpsport.h \ jeeps/gpsmath.h jeeps/gpsnmea.h jeeps/gpsmem.h jeeps/gpsrqst.h \ jeeps/gpsinput.h jeeps/gpsproj.h jeeps/gpsnmeafmt.h jeeps/gpsnmeaget.h internal_styles.c: mkstyle.sh style/README.style style/csv.style style/custom.style style/dna.style style/fugawi.style style/gpsdrive.style style/gpsman.style style/mxf.style style/nima.style style/ozi.style style/s_and_t.style style/xmap.style style/xmapwpt.style - ./mkstyle.sh > $@ || rm -f $@ ; exit 1 + ./mkstyle.sh > $@ || (rm -f $@ ; exit 1) diff --git a/gpsbabel/geo.c b/gpsbabel/geo.c index 86dd7850b..c3ff29c4c 100644 --- a/gpsbabel/geo.c +++ b/gpsbabel/geo.c @@ -22,8 +22,10 @@ static int in_wpt; static int in_name; static int in_link; +static int in_type; static int in_cdata; static char *cdatastr; +static char *typestr; static XML_Parser psr; static waypoint *wpt_tmp; @@ -65,6 +67,18 @@ tag_name(const char **attrv) } } +static void +tag_type(const char **attrv) +{ + const char **avp = &attrv[0]; + while (*avp) { + if (strcmp(avp[0], "type") == 0) { + wpt_tmp->icon_descr = xstrdup(avp[1]); + } + avp+=2; + } +} + static void tag_link(const char **attrv) { @@ -91,6 +105,9 @@ geo_start(void *data, const char *el, const char **attr) else if (strcmp(el, "coord") == 0) { tag_coord(attr); } + else if (strcmp(el, "type") == 0) { + tag_type(attr); + } } if (strcmp(el, "waypoint") == 0) { @@ -98,6 +115,9 @@ geo_start(void *data, const char *el, const char **attr) in_wpt++; } else if (strcmp(el, "name") == 0) { in_name++; + } else if (strcmp(el, "type") == 0) { + tag_type(attr); + in_type++; } else if (strcmp(el, "link") == 0) { tag_link(attr); in_link++; @@ -124,6 +144,11 @@ geo_end(void *data, const char *el) else if (strcmp(el, "name") == 0) { in_name--; } + else if (strcmp(el, "type") == 0) { + wpt_tmp->icon_descr = xstrdup(typestr); + memset(typestr,0, MY_CBUF); + in_type--; + } else if (strcmp(el, "link") == 0) { in_link--; } @@ -138,6 +163,10 @@ geo_cdata(void *dta, const XML_Char *s, int len) memcpy(estr, s, len); in_cdata++; } + if (in_type) { + estr = typestr + strlen(typestr); + memcpy(estr, s, len); + } } void @@ -155,6 +184,7 @@ geo_rd_init(const char *fname, const char *args) XML_SetElementHandler(psr, geo_start, geo_end); cdatastr = xcalloc(MY_CBUF,1); + typestr = xcalloc(MY_CBUF,1); XML_SetCharacterDataHandler(psr, geo_cdata); } @@ -164,6 +194,9 @@ geo_rd_deinit(void) if ( cdatastr ) { xfree(cdatastr); } + if ( typestr ) { + xfree(typestr); + } fclose(fd); } @@ -212,6 +245,9 @@ geo_waypt_pr(const waypoint *waypointp) waypointp->position.longitude.degrees); fprintf(ofd, "\n"); + if (waypointp->icon_descr) { + fprintf(ofd, "%s\n", waypointp->icon_descr); + } if (waypointp->url) { fprintf(ofd, "%s\n", waypointp->url); diff --git a/gpsbabel/internal_styles.c b/gpsbabel/internal_styles.c index b7334434f..abb612bd8 100644 --- a/gpsbabel/internal_styles.c +++ b/gpsbabel/internal_styles.c @@ -163,10 +163,10 @@ static char gpsdrive[] = "#\n" "FIELD_DELIMITER SPACE\n" "RECORD_DELIMITER NEWLINE\n" -"BADCHARS ,\"\n" +"BADCHARS ,'\"\n" -"SHORTLEN 20\n" -"SHORTWHITE 0\n" +"SHORTLEN 20\n" +"SHORTWHITE 0\n" "#\n" "# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n" @@ -174,10 +174,12 @@ static char gpsdrive[] = "IFIELD SHORTNAME, \"\", \"%s\"\n" "IFIELD LAT_DECIMAL, \"\", \"%08.5f\"\n" "IFIELD LON_DECIMAL, \"\", \"%08.5f\"\n" +"IFIELD ICON_DESCR, \"\", \"%s\"\n" "OFIELD ANYNAME, \"\", \"%s\"\n" "OFIELD LAT_DECIMAL, \"\", \"%08.5f\"\n" "OFIELD LON_DECIMAL, \"\", \"%08.5f\"\n" +"OFIELD ICON_DESCR, \"\", \"%s\"\n" ; static char gpsman[] = "# gpsbabel XCSV style file\n" diff --git a/gpsbabel/reference/gl.loc b/gpsbabel/reference/gl.loc index f514e8627..192d169f2 100644 --- a/gpsbabel/reference/gl.loc +++ b/gpsbabel/reference/gl.loc @@ -2,46 +2,55 @@ +geocache http://www.geocaching.com/seek/cache_details.asp?ID=3771 +geocache http://www.geocaching.com/seek/cache_details.asp?ID=6711 +geocache http://www.geocaching.com/seek/cache_details.asp?ID=7211 +geocache http://www.geocaching.com/seek/cache_details.asp?ID=9641 +geocache http://www.geocaching.com/seek/cache_details.asp?ID=10019 +geocache http://www.geocaching.com/seek/cache_details.asp?ID=11121 +geocache http://www.geocaching.com/seek/cache_details.asp?ID=12447 +geocache http://www.geocaching.com/seek/cache_details.asp?ID=12666 +geocache http://www.geocaching.com/seek/cache_details.asp?ID=12669 diff --git a/gpsbabel/reference/gpsdrive.txt b/gpsbabel/reference/gpsdrive.txt index 65e18b8a8..901eb1c84 100644 --- a/gpsbabel/reference/gpsdrive.txt +++ b/gpsbabel/reference/gpsdrive.txt @@ -1,9 +1,9 @@ -GCEBB 35.97203 -87.13470 -GC1A37 36.09068 -86.67955 -GC1C2B 35.99627 -86.62012 -GC25A9 36.03848 -86.64862 -GC2723 36.11218 -86.74177 -GC2B71 36.06408 -86.79052 -GC309F 36.08777 -86.80973 -GC317A 36.05750 -86.89200 -GC317D 36.08280 -86.86728 +GCEBB 35.97203 -87.13470 geocache +GC1A37 36.09068 -86.67955 geocache +GC1C2B 35.99627 -86.62012 geocache +GC25A9 36.03848 -86.64862 geocache +GC2723 36.11218 -86.74177 geocache +GC2B71 36.06408 -86.79052 geocache +GC309F 36.08777 -86.80973 geocache +GC317A 36.05750 -86.89200 geocache +GC317D 36.08280 -86.86728 geocache diff --git a/gpsbabel/style/gpsdrive.style b/gpsbabel/style/gpsdrive.style index 236c07595..96cbda45f 100644 --- a/gpsbabel/style/gpsdrive.style +++ b/gpsbabel/style/gpsdrive.style @@ -13,10 +13,10 @@ DESCRIPTION GpsDrive Format # FIELD_DELIMITER SPACE RECORD_DELIMITER NEWLINE -BADCHARS ," +BADCHARS ,'" -SHORTLEN 20 -SHORTWHITE 0 +SHORTLEN 20 +SHORTWHITE 0 # # INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE: @@ -24,7 +24,9 @@ SHORTWHITE 0 IFIELD SHORTNAME, "", "%s" IFIELD LAT_DECIMAL, "", "%08.5f" IFIELD LON_DECIMAL, "", "%08.5f" +IFIELD ICON_DESCR, "", "%s" OFIELD ANYNAME, "", "%s" OFIELD LAT_DECIMAL, "", "%08.5f" OFIELD LON_DECIMAL, "", "%08.5f" +OFIELD ICON_DESCR, "", "%s" -- 2.30.2